import router from "./index";
import store from '../store'
export default function () {
  router.beforeEach(function (to, from, next) {

    store.state.urls = to.path;
    // next();


    if (sessionStorage.getItem('author_token')) { // 判断是否登录
      next()
    } else if (to.path === '/login') {
      next()
    } else if (to.path.indexOf("/admin") != -1) {
      sessionStorage.clear()
      next({
        path: '/login'
      })
    } else {
      sessionStorage.clear()
      next({
        path: '/login'
      })
    }
  });
}
